package com.weilx959.spt.plugin.e2sp.constant;

import com.weilx959.spt.plugin.e2sp.utils.expression.deparser.MySQLExpressionDeParser;
import com.weilx959.spt.plugin.e2sp.utils.expression.deparser.OracleExpressionDeParser;
import com.weilx959.spt.plugin.e2sp.utils.expression.deparser.PostgreSQLExpressionDeParser;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import net.sf.jsqlparser.util.deparser.ExpressionDeParser;

@Getter
@RequiredArgsConstructor
public enum Dialect {
    ORACLE("Oracle", OracleExpressionDeParser.class),
    MYSQL("MySQL", MySQLExpressionDeParser.class),
    POSTGRESQL("PostgreSQL", PostgreSQLExpressionDeParser.class);

    private final String value;

    private final Class<? extends ExpressionDeParser> deparserClass;

    public static Dialect of(String value) {
        for (Dialect dialect : Dialect.values()) {
            if (dialect.getValue().equalsIgnoreCase(value)) {
                return dialect;
            }
        }
        return null;
    }
}
